<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title></title>
<link href="houtai/css/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="houtai/js/main.js"></script>
<script type="text/javascript">
	var xmlhttp;
	function ckmenname() {

		var menname = document.getElementById("menname").value;
		var id = document.getElementById("id").value;
		if (menname == "") {
			document.getElementById("spnmname").innerHTML="请输入菜单名";
			document.getElementById("spnmname").style.color="red";
			return false;
		}
		document.getElementById("spnmname").innerHTML="";
	
		xmlhttp = new XMLHttpRequest();
		xmlhttp.onreadystatechange = ckmname;

		xmlhttp.open("get", "MenuServlet?param=ajaxmenuname&id="+id
						+ "&menname=" + menname + "&time="
						+ new Date().getTime(), true);
		xmlhttp.send(null);
	}
	function ckmname() {
		if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
			var txt=xmlhttp.responseText;
			document.getElementById("spnmname").innerHTML = txt;
			if(txt=="√"){
				document.getElementById("spnmname").style.color="green";
			}else{
				document.getElementById("spnmname").style.color="red";
			}
		}
	}

	function ckname() {
		if (document.getElementById("menname").value == "") {
			document.getElementById("spnmname").innerHTML="请输入菜单名";
			document.getElementById("spnmname").style.color="red";
			return false;
		}
		document.getElementById("spnmname").innerHTML="";
		return true;
	}


	function ckurl() {
		var menurl = document.getElementById("menurl").value;
		if (menurl == "") {
			document.getElementById("s1").innerHTML="请输入url路径";
			document.getElementById("s1").style.color="red";
			return false;
		}
		return true;
	}
	
	
	function ckremark(){
		if(document.getElementById("menremark").value==""){
			document.getElementById("s11").innerHTML="备注不能为空";
			document.getElementById("s11").style.color="red";
			return false;
		}
		document.getElementById("s11").innerHTML="";
		return true;
	}
	
	
	function check() {
		if (ckname()&&ckremark()) {
			var fmen = document.getElementById("fmenid").value;
			if (fmen != -1) {
				if (ckurl()) {
					if (confirm("确定保存吗？")) {
						document.getElementById("form1").submit();
						return true;
					}
				}else{
					return false;
				}
			}else{
				if (confirm("确定保存吗？")) {
					document.getElementById("form1").submit();
					return true;
				}
			}
		}
		return false;

	}
</script>
</head>
<body>
	<table width="100%" height="100%" border="0" cellspacing="0"
		cellpadding="3">
		<tr>
			<td style="height:25px; background-color:#f3f3f3; font-weight:bold"
				valign="top">&nbsp;&nbsp;&nbsp;&nbsp;当前位置： <img
				src="houtai/images/arrow.gif" align="absmiddle">&nbsp;&nbsp;soda创业教育平台&nbsp;&nbsp;
				<img src="houtai/images/arrow.gif" align="absmiddle">&nbsp;&nbsp;后台管理&nbsp;&nbsp;
				<img src="houtai/images/arrow.gif" align="absmiddle">&nbsp;&nbsp;菜单管理
			</td>
		</tr>
		<tr>
			<td
				style="height:34px; background-image:url(houtai/images/main_header.gif); border-bottom:1px solid #cfd8e0; padding:0px">
				<table width="100%" border="0" cellspacing="0" cellpadding="0">
					<tr>
						<td width="20" height="34"><img
							src="houtai/images/main_headerL.gif" width="20" height="34"></td>
						<td style="color:#90c8e8;"><img
							src="houtai/images/icon_card.gif" width="16" height="16"
							align="absmiddle">&nbsp;&nbsp;<strong>修改菜单信息</strong></td>
						<td align="right" class="white" style="padding-right:20px"><a
							 class="barBtn"
							onClick="javascript:history.go(-1);"><img
								src="houtai/images/btn_left.gif" align="absmiddle"> 后退</a> <a
							 class="barBtn"
							onClick="javascript:history.go(+1);"><img
								src="houtai/images/btn_right.gif" align="absmiddle"> 前进</a> <a
							href="javascript:history.go(0);" class="barBtn"><img
								src="houtai/images/btn_refresh.gif" align="absmiddle"> 刷新</a>
						</td>
					</tr>
				</table>
			</td>
		</tr>
		<tr>
			<td height="100%" valign="top">
				<div style="overflow:auto;height:100%; width:100%">
					<form id="form1"
						action="<%=request.getContextPath()%>/MenuServlet?param=saveMenuInfo"
						method="post">
						<table width="100%" border="0" cellpadding="3" cellspacing="1"
							class="table1">
							<TR>
								<input type="hidden" name="id" id="id" value="${menu.rank }" />
								<th width="20%" align="center">菜单名</th>
								<TD class="BGCgray"><input type="text" name="menname"
									id="menname" onblur="ckmenname()" value="${menu.fmeName}" /><span
									id="spnmname"></span></TD>
							</TR>
							<TR>
								<th width="20%" align="center">父级菜单</th>
								<TD class="BGCgray"><select name="fmenid" id="fmenid"
									${menu.url==''?"disabled='disabled'":""}>
										<option value="-1" ${menu.url==""?"selected='selected'":"disabled='disabled'"}>顶级菜单</option>

										<c:forEach items="${fmenus }" var="fmenu">
											<option value="${fmenu.fmeId }"
												${menu.url!=''&&fmenu.fmeId==menu.number?"selected='selected'":"" }>${fmenu.fmeName }</option>
										</c:forEach>

								</select></TD>
							</TR>

							<TR ${menu.url==""?"style='display: none;'":"" }>
								<th width="20%" align="center">url路径</th>
								<TD class="BGCgray"><input type="text" name="menurl"
									id="menurl" value="${menu.url }" /><span id="s1"></span></TD>
							</TR>

							<TR>
								<th align="center">启用状态</th>
								<TD class="BGCgray"><input type="radio" name="menstate"
									${menu.url==''?"disabled='disabled'":""} value="1"
									${menu.fmeState==1?"checked='checked'":"" } />启用 <input
									type="radio" name="menstate" value="0"
									${menu.url==''?"disabled='disabled'":""}
									${menu.fmeState==0?"checked='checked'":"" } />禁用</TD>
							</TR>
							<TR>
								<th align="center"><span class="BGCgray">备注</span></th>
								<TD class="BGCgray"><textarea name="menremark" onblur="ckremark()"
										id="menremark">${menu.fmeRemark }
            </textarea><span id="s11"></span></TD>
							</TR>
						</table>
						<div style="width:100%; text-align:center; padding:5px">
							<BUTTON onclick="return check()" style="HEIGHT:25px">
								<img src="houtai/images/btn_edit.gif" width="16" height="16"
									align="absmiddle"> 修改
							</BUTTON>
							<BUTTON style="HEIGHT:25px" onClick="history.go(-1);">
								<img src="houtai/images/btn_back.gif" width="16" height="16"
									align="absmiddle"> 返回
							</BUTTON>
						</div>
				</div>
			</td>
		</tr>
		</form>
	</table>
</body>
</html>